import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;


@Component
public class MyTask {

    @Scheduled(cron = "0/5 * * * * *")

    public void showTime(){
        System.out.println("定时任务开始执行:"+new Date());

    }

}



class testTask {


    public static void main(String[] args) {


        while(true) {
            MyTask myTask = new MyTask();
            myTask.showTime();
        }


    }

}